<?php
require_once S_ROOT . '/libraryfiles/cart-functions.php';
$orderfrom = $_GET['id'];  //get id value from url from page order

$sel_ord = mysql_query("SELECT * , pro.id AS productId FROM tbl_order_item AS porderi
                        INNER JOIN tbl_order AS porder ON porderi.od_id=porder.od_id
                        INNER JOIN tblproduct_in_pharmacy AS pip ON pip.pid=porderi.pd_id
                        INNER JOIN tblproduct AS pro ON pro.id=pip.product_id
                        INNER JOIN tblimage AS img ON pro.id=img.product_id
                        WHERE porderi.od_id = '" . $orderfrom . "' AND pip.pharmacy_id = '".$_SESSION['acc_id']."'");
?> 

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
<style>
    .toggler
    {
        margin: 10px 0 0 0;
    }
    .button {		
        text-decoration: none;        
    }
    .point
    {
        cursor: pointer;
    }
    #effect {
        position: relative;
        padding: 0.4em;
    }
    h3.statistic {
        margin: 0;
        padding: 0.4em;
        text-align: left;
        font-size: 14px;
        display:block;
    }
    .t_none
    {
        border:none;
    }
</style>
<div style="margin: 10px 15px 0 0;">
    <h3 class="statistic ui-widget-header ui-corner-all"><!--Order--><?php echo $lang['SELL_ORDER']; ?></h3>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">

        <tr>
            <th><strong>ID</strong></th>
            <th><strong>Images</strong></th>
            <th><strong>Product name</strong></th>
            <th><strong>Quantity</strong></th>
            <th><strong>Price</strong></th>
            <th><strong>Total</strong></th>
        </tr>

        <?php
      
        $tol_price = array();
        $ship_contact = array();
        
        while ($rows = mysql_fetch_assoc($sel_ord)) {
            $total_price = $rows['od_qty'] * $rows['price'];

           
            $tol_price[] = array('pro_pri' => $total_price);
            
            $ship_contact[] = array('firstName' => $rows['od_shipping_first_name'], 'lastName' => $rows['od_shipping_last_name'], 'address' => $rows['od_shipping_address'], 'tel' => $rows['od_shipping_telephone'], 'email' => $rows['od_shipping_email']);
            ?>
            <?php
            ?>

            <tr>
                <td width="1%" align="center"><?php echo $rows['id']; ?></td>
                <td width="2%" align="center"><img height="50" width="50" style="float: left;" class="img-active" src="<?php echo W_S_IMAGES_DIR . $rows['thumbnail']; ?>" /></td>
                <td width="2%" align="center"><a href="<?php echo W_ROOT;?>/product/product_detail.php?product_id=<?php echo $rows['productId']?>" target="_blank" title="<?php echo $rows['product_name']; ?>"><?php echo $rows['product_name']; ?></a></td>
                <td width="1%" align="center"><?php echo $rows['od_qty']; ?></td>
                <td width="1%" align="center"><?php echo $rows['price']; ?> $</td>
                <td width="1%" align="center"><?php echo $rows['od_qty'] * $rows['price']; ?>&nbsp;$</td>
            </tr>
            <?php
        } //.................End while.....................
        ?>
        <?php
        $sum = 0;
        foreach ($tol_price as $value) {

            $sum = $sum + $value['pro_pri'];
        }
        //echo $sum;
        ?>
        <tr>
            <td colspan="4"></td>
            <td >Total :</td>
            <td><strong><?php echo $sum; ?>&nbsp;$</strong></td>
        </tr>


        <tr bgcolor="#a5a3a4"><td colspan="6"></td></tr>
    </table>
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <?php
                //var_dump($ship_contact);
                foreach ($ship_contact as $key => $value) {
                    $ship_fname = $value['firstName'];
                    $ship_lname = $value['lastName'];
                    $ship_adr = $value['address'];
                    $ship_tel = $value['tel'];
                    $ship_email = $value['email'];
                    
                }                                               
                
        ?>
        <tr>
            <td><strong>Customer Name:</strong></td>
            <td><?php echo $ship_fname . " " . $ship_lname; ?></td>
        </tr>
        <tr>
            <td><strong>Customer Address:</strong></td>
            <td><?php echo $ship_adr; ?></td>
        </tr>
        <tr>
            <td><strong>Customer Phone:</strong></td>
            <td><?php echo $ship_tel; ?></td>
        </tr>
        <tr>
            <td><strong>Customer Email:</strong></td>
            <td><?php echo $ship_email; ?></td>
        </tr>

    </table>
</div>

